unit ErrorLabel;

{$R 'CPControls\ErrorGlyph.res'}

interface

uses
  SysUtils, Classes, Controls, ExtCtrls, Windows, Graphics, Buttons;

type
  TErrorLabel = class(TSpeedButton)
  private
    FData: TObject;
    procedure SetData(const Value: TObject);
  public
    destructor Destroy; override;
    property Data: TObject read FData write SetData;
    procedure AfterConstruction; override;

  end;

procedure Register;

implementation

var Glyph: TBitmap;

procedure Register;
begin
  RegisterComponents('CPControls', [TErrorLabel]);
end;

{ TErrorLabel }

procedure TErrorLabel.AfterConstruction;
begin
  inherited;
  Flat := true;
  FData := nil;
  Glyph := ErrorLabel.Glyph;
end;

destructor TErrorLabel.Destroy;
begin
  FData.Free;
  inherited;
end;

procedure TErrorLabel.SetData(const Value: TObject);
begin
  if Value <> FData then
  begin
    FData.Free;
    FData := Value;
  end;
end;

function enumResNamesProc(module: HMODULE; restype, resname: PChar;
  Data: Pointer): Integer; stdcall;
begin
  Writeln(resname);
  Result := 1;
end;

function enumResTypesProc(module: HMODULE; restype: PChar; Data: Pointer): Integer; stdcall;
begin
  EnumResourceNames(module, restype, @enumResNamesProc, 0);
  Result := 1;
end;

initialization

Glyph := TBitmap.Create;
Glyph.LoadFromResourceName(HInstance, 'ErrorGlyph');



finalization

Glyph.Free;

end.
